import { useRouter, useRoute } from 'vue-router'
import { useTagStore } from '@/stores/layout'

export default function useRouteReplace(path: string) {
  const route = useRoute()
  const router = useRouter()
  const tagStore = useTagStore()

  return () => {
    tagStore.closeTag(route.fullPath)
    tagStore.closeTagByName(route.name as string)
    router.replace(path)
  }
}
